<template>
  <div class="menuClass" :style="{height: styleHeight + 'px'}">
    <div class="colorChange">
      <p>主题色：</p>
      <el-switch v-model="colorSelect" active-color="#E6A23C" inactive-color="#128dff"  active-value="orange" inactive-value="blue"></el-switch>
    </div>
    <el-radio-group v-model="isCollapse" style="margin-bottom: 20px;">
      <el-radio-button :label="false">展开</el-radio-button>
      <el-radio-button :label="true">收起</el-radio-button>
    </el-radio-group>
    <el-menu default-active="1-4-1" class="el-menu-vertical-demo" @open="handleOpen" @close="handleClose" :collapse="isCollapse">
      <el-menu-item index="1">
        <i class="el-icon-location"></i>
        <span slot="title">导航一</span>
      </el-menu-item>
      <el-menu-item index="2">
        <i class="el-icon-menu"></i>
        <span slot="title">导航二</span>
      </el-menu-item>
      <el-menu-item index="3" disabled>
        <i class="el-icon-document"></i>
        <span slot="title">导航三</span>
      </el-menu-item>
      <el-menu-item index="4">
        <i class="el-icon-setting"></i>
        <span slot="title">导航四</span>
      </el-menu-item>
    </el-menu>
  </div>
</template>

<script>
  import {winHeight} from '@/tools/command.js'
  import { mapActions } from 'vuex'
  export default {
    data() {
      return {
        colorSelect: true,
        styleHeight: winHeight(),
        isCollapse: false
      };
    },
    mounted () {
      console.log(this.winHeight())
    },
    computed: {
      localHeight: function () {
        return winHeight()
      }
    },
    watch: {
      localHeight: function (val, oldval) {
        this.styleHeight = val
      },
      colorSelect: function (val) {
        this.setSkinClass(val)
      }
    },
    methods: {
      winHeight,
      ...mapActions({
        setSkinClass : 'setSkinClass'
      }),
      handleOpen(key, keyPath) {
        console.log(key, keyPath);
      },
      handleClose(key, keyPath) {
        console.log(key, keyPath);
      }
    }
  }
</script>
<style lang="less">
  .el-menu-vertical-demo:not(.el-menu--collapse) {
    width: 200px;
    min-height: 400px;
  }
</style>
<style lang="less" scoped>
  .menuClass {
    .colorChange {
      height: 60px;
    }
  }
</style>